home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / keyb / keybuf21.zip / KEYBUF.DOC < prev   
Text File  |  1994-01-20  |  9KB  |  190 lines

  1. ARCHIVE NAME : VRKBUF21.ZIP
  2. PROGRAM NAME : KeyBuf (c) 1992-1994
  3. VERSION      : 2.10
  4. PROGRAM TYPE : Tool (BIOS patcher)
  5. DISTRIBUTION : PUBLIC DOMAIN (with restrictions)
  6. PURPOSE      : Expands the keyboard buffer to 128 keystrokes
  7. AUTHOR       : Vincenzo ROMANO
  8. ADDRESS      : Via A.Omodeo, 3
  9.            I-56124 Pisa  ITALY
  10. E-MAIL       : vromano@NYX.cs.du.edu
  11. RELEASED     : 20 Jan. 1994
  12. REQUIREMENTS : AT-class BIOS, DOS 2.1+ (read below)
  13.  
  14. 0 - DISCLAIM and LEGAL STUFF
  15.         .-----------------------------------------------.
  16.                 | THIS PROGRAM IS ABSOLUTELY FREE OF ANY CHARGE |
  17.         | FOR NON-COMMERCIAL AND NON-PROFITABLE USES.   |
  18.         | FOR COMMERCIAL OR PROFITABLE USES YOU HAVE TO |
  19.         | CONTACT THE AUTHOR BEFORE USING IT.           |
  20.         | THE AUTHOR WILL NOT BE RESPONSIBLE IN ANY WAY |
  21.         | OF ANY KIND OF DAMAGE DUED TO THE USE OF THIS |
  22.         | PROGRAM.                                      |
  23.         | YOU CAN  RE-DISTRIBUTE  THIS PROGRAM PROVIDED |
  24.         | THAT THIS  DOCUMENTATION  FILE IS DISTRIBUTED |
  25.         | ALONG WITH THE PROGRAM ITSELF.                |
  26.                 | IF YOU RE-DISTRIBUTE  THIS PROGRAM YOU CANNOT |
  27.         | CHARGE IT FOR MORE THAN THE COST OF THE MEDIA |
  28.         | SUPPORT.                                      |
  29.                 | THE USE AND  RE-DISTRIBUTION OF  THIS PROGRAM |
  30.         | IMPLY THE AGREEMENT TO THE STATEMENTS ABOVE.  |
  31.         `-----------------------------------------------'
  32.  
  33. 1 - INTRODUCTION
  34.           Any PC has a memory buffer to keep the  keystrokes not already
  35.         read.
  36.           Unluckyly this  buffer  is set to be only 16  keystrokes long:
  37.     this could not be a problem for  some  people  while it does for
  38.     many others ( like me ).
  39.           Let's say that we want to  run  these  programs while having a
  40.     coffee break:
  41.  
  42.     CHKDSK /F C:
  43.     DEL C:\*.CHK
  44.     DEFRAG C:\ /QUIET
  45.  
  46.           The time needed  to  accomplish  this  task  can be very long,
  47.     especially because you have to  wait for the CHKDSK to finish. A
  48.     keyboard buffer too short doesn't  help you: you cannot type the
  49.     three command lines and then go away.  This is only one example!
  50.           And then, what's the solution? It's easy to answer: write your
  51.     own keyboard buffer expander or use KeyBuf!
  52.       Now it's time to tell you  something. When you type characters
  53.     ahead, you have to know  what  you're  going to do: computers do
  54.     exactly what you asked them to. Nothing more, nothing less!
  55.       When  you  hit ^C ( Control-C ) or BREAK ( Control-Pause ) the
  56.     BIOS will erase any unread keystrokes from the buffer: this is a
  57.     BIOS feature, not a KeyBuf one.
  58.  
  59. 2 - HOW DOES KeyBuf WORK?
  60.         .-----------------------------------------------.
  61.                 | These are technical notes. You're required to |
  62.         | know  some  low  level  knowledges  to  fully |
  63.         | understand them ( offsets, segments, etc. ).  |
  64.                 `-----------------------------------------------'
  65.  
  66.           The standard PC  BIOSes ( Basic I/O System )  store a circular
  67.     buffer for the unread keystrokes (2 bytes each) in a memory area
  68.     called BVS ( BIOS Variables Segment ) located at 0040:0000h.
  69.           To  manage  this  circular  buffer  the  BIOS  needs  of  four
  70.     pointers, namely:
  71.  
  72.           head : the next place where the BIOS will put a new keystroke,
  73.           tail : the next place  from  where  the BIOS gets a keystroke,
  74.           bot  : the starting address of the buffer,
  75.           top  : the upper limit of the buffer.
  76.  
  77.     buffer for the unread keystrokes (2 bytes each) in a memory area
  78.           Anytime we ask the BIOS for a keystroke,  the value pointed by
  79.         `tail' is read and the pointer advanced  ( if we reach `top' the
  80.         BIOS wraps it to `bot' ).
  81.           Anytime we hit a key, the BIOS  stores  the new keystroke into
  82.     the two bytes pointed by `head' and advances the pointer ( if we
  83.         reach `top' ... ).
  84.           If `head' reaches  `tail'  we  are  running  out of the buffer
  85.     space and will lost this keystroke and subsequent ones.
  86.           If `tail' reaches `head' we have emptied the buffer.
  87.           In XT-class BIOSes, the `bot'  and `top' values are hard coded
  88.     into the ROM and we can't solve the problem ( unless we re-write
  89.     the BIOS keyboard manager ).
  90.           In AT-class BIOSes they are stored  as real variables into the
  91.     BVS. So we'd need only to  set  some  new values into those four
  92.     variables to set a brand new keyboard buffer.
  93.       But we're only starting the dances!
  94.           The four pointers are stored  as  OFFSETs: the SEGMENT is hard
  95.     coded to be the BVS.  We cannot put  the new buffer anywhere: it
  96.     is to be within the 64 Kb limit of the BVS, that is its `top' is
  97.     to be lower than 1040:0000h in memory.
  98.           I.e., if we want a 256  bytes buffer,  it can be set in memory
  99.     as high as:
  100.  
  101.       1040:0000h - 256 = 10400h - 100h = 10300h = 1030:0000h.
  102.  
  103.           Usually, the PC memory is allocated as follows:
  104.  
  105.           Segment | Lenght | Description
  106.           --------|--------|---------------
  107.            0000h  |  1024  | Interrupts vector
  108.            0040h  |   256  | BIOS Variables Segment
  109.            0050h  |   512  | DOS System Variables {can vary in lenght}
  110.            0070h  |  ????  | BIOS extensions ( IO.SYS )
  111.            ????h  |  ????  | DOS handlers ( MSDOG.SYS )
  112.            ????h  |  ????  | DOS buffers, data and device drivers
  113.            ????h  |  ????  | Resident portion of the shell (COMMAND.COM)
  114.            ????h  |  ????  | TSRs and programs
  115.  
  116.           Maybe that all the memory  below the 1040:0000h limit is busy:
  117.     we cannot allocate a new keyboard buffer.
  118.           If we are running  MS-DOG 5.0+  or are using some system tool,
  119.     we can move the last three  `memory eaters' somewhere else ( the
  120.     HMA and the UMBs ) thus freeing our precious lower memory.  This
  121.     is the best case to use KeyBuf!
  122.           Anytime we run a program after the boot procedure (CONFIG.SYS)
  123.         the DOS allocates  two  memory  blocks for it: one for a copy of
  124.     the variables environment and one, just above the first, for the
  125.     program itself.
  126.           So, the lowest memory block  we  can use is the environment if
  127.     it's large enough, that is if it's 256 bytes long at least.
  128.       If the environment is too tight, KeyBuf tries to allocate some
  129.     other memory.
  130.           This should not be a problem today: lots of programs need some
  131.     environment variable  to  run  and  the  users  set environments
  132.     larger than 256 bytes!
  133.           KeyBuf allocates/deallocates  memory by using the standard DOS
  134.     memory services ( services 48h and 49h of int21h ) as introduced
  135.     in the MS-DOG 2.1+ .
  136.       Now you can understand that  KeyBuf  is  not  a TSR but only a
  137.     BIOS patcher: KeyBuf doesn't steal CPU time!
  138.           For more details please read the source code.
  139.  
  140. 3 - HOW TO USE KeyBuf
  141.  
  142.       Usually you have only to put  KeyBuf in some directory of your
  143.     hard disk and add a line in your AUTOEXEC.BAT file to call it as
  144.     high as possible.  In other words you should run KeyBuf as early
  145.     as possible in your boot sequence.
  146.       To see if KeyBuf `really'  got  installed,  try to run it once
  147.     again: KeyBuf will complain if run twice.
  148.       No installation procedure is needed.
  149.           If you're running some TSR  that  accesses the keyboard buffer
  150.     pointers (like the ones that  automatically  generate keystrokes
  151.     to force a "file save"), be sure to call KeyBuf BEFORE them.
  152.       I think you can assemble KeyBuf  as a device driver too to put
  153.     it in the CONFIG.SYS by slightly modifying its sources.
  154.       I have never tried such a thing.
  155.       One more thing.  If your `environment space'  is less than 256
  156.     bytes long,  maybe you'll get an error  message telling you that
  157.     "all memory below 1030:0 is busy" even if your memory below 1030
  158.     is not all used.
  159.       If you like  this  program  or  use it,  I'd like to receive a
  160.     postcard of your country  or of your city.  Please, feel free to
  161.     contact me for suggestions and bug reports.
  162.  
  163. 4 - HISTORY
  164.  
  165.         0.8 [9 Apr. 1992]
  166.       Used only by me and by my friends
  167.  
  168.     1.0 [17 Oct. 1992]
  169.       Added comments to the sources. Interrupts get disabled.
  170.  
  171.     2.0 [